function f=ff2(x,A,B)
x1=A(:,1);y=A(:,2);z=A(:,3);
f=sum((x1-x(1)).^2+(y-x(2)).^2+(z-(B(1)*x(1)+B(2)*x(2)+B(3))).^2);